<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ page import="board1.ReplyDAO"%>
<%@ page import="board1.ReplyTO"%>
<%@ page import="java.util.ArrayList"%>

<%
	request.setCharacterEncoding("UTF-8");

	int cpage = 1;

	String sIdx = request.getParameter("idx");

	if (request.getParameter("cpage") != null
			&& !request.getParameter("cpage").equals("")) {
		cpage = Integer.parseInt(request.getParameter("cpage"));
	}

	ReplyDAO dao = new ReplyDAO();

	ArrayList<ReplyTO> data = dao.listReply(sIdx);

	String reply_list = "";

	for (int i = 0; i < data.size(); i++) {
		ReplyTO to = (ReplyTO) data.get(i);
		String phone_number = to.getPhone_number();
		String idx = to.getIdx();
		String subcontent = to.getSubcontent();

		if (i == 0) {
			reply_list = "{" + "\"phone_number\"" + ":\""
					+ phone_number + "\"," + "\" subcontent\"" + ":\""
					+ subcontent + "\"," + "\" idx\"" + ":\"" + idx
					+ "\"}";
		} else {
			reply_list += ",{" + "\"phone_number\"" + ":\""
					+ phone_number + "\"," + "\" subcontent\"" + ":\""
					+ subcontent + "\"," + "\" idx\"" + ":\"" + idx
					+ "\"}";
		}
	}

	if (reply_list.equals(""))
		reply_list = "FAIL";
	else
		reply_list = "[" + reply_list + "]";

	out.println(reply_list);
%>